import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
import a001 from './a001';
export default async function a004(fd: IFeidaoAiBrowserComponent, e: Event) {
	// todo

	const n = e.target as HTMLDivElement;
	const v = n.getAttribute("data-id");
	const flag = n.getAttribute("data-flag");
	const ns = fd.data.node.querySelectorAll('[data-asc="desc"]');

	Array.from(ns).forEach((value: HTMLDivElement) => {
		value.setAttribute("class", "iconfont cursor-p icon-shangxia color-3 font14 pos-a");
	});
	// 用于接收升序或降序的字段
	let asc: string = '';
	let desc: string = '';
	if (flag === '1') {
		// 升序
		n.setAttribute('data-flag', '0');
		n.setAttribute("class", "iconfont cursor-p icon-shang color-3 font14 pos-a");
		asc = v;
	} else {
		// 降序
		n.setAttribute('data-flag', '1');
		n.setAttribute("class", "iconfont cursor-p icon-xia color-3 font14 pos-a");
		desc = v;
	}

	set(fd, 'asc', asc);
	set(fd, 'desc', desc);
	await a001(fd, { page_no: 1 });

}
